Component({
  properties: {
    title: {
      type: String,
      value: ' 点击 “...” 添加到我的小程序',
    },
    content: {
      type: String,
      value: '微信首页下拉即可快速找到我们',
    },
    interval: {
      type: Number,
      value: 5000,
    },
    topNum: {
      type: Number,
      value: 10,
    }
  },
  externalClasses: [
    'popover-class',
    'content-class',
    'arrow-class',
    'info-class',
    'infotitle-class',
    'infocontent-class',
  ],
  data: {
    showPopover: false,
  },
  ready() {
    this._handleShow();
  },
  methods: {
    _handleShow() {
      const hasPopover = wx.getStorageSync('hasPopover');
      const { 
        interval = 5000,
      } = this.data;

      if (hasPopover) return;
      this.setData({
        showPopover: !hasPopover,
      });

      setTimeout(() => {
        this._handleHide();
      }, interval);
    },

    _handleHide() {
      const {
        showPopover,
      } = this.data;

      this.setData({
        showPopover: !showPopover,
      });

      wx.setStorageSync('hasPopover', showPopover);
    },
  },
});